#KEY:S-Delete
#KEY:SC-Delete

return unless defined $kf;

return -1 if(defined($keyin)&&@_); # want to run as nk-com

my $del=sub{
    my $f=&get_fn($_[0]);
    if(unlink($f)){
	&mess("deleted: $f\n");
    }else{
	&mess(($tmpmsg="failed to delete: $f")."\n","ERR");
    }
};

if(ref($_[0])){ # run as nk-com
    my ($psetv,$pseti,$n,$prm)=@_;
    my $k=$pseti->($psetv->($kf+1));
    return 1 unless defined $k; # to next
    $stats[$k]="D";
    $del->($k);
    $$prm=1;
    return 1; # to next
}

if($ctrl){
    for(my $k=$#files;$k>=0;$k--){
	$del->($k) if substr($stats[$k],0,1);
    }
}else{
    if($tnvmode>=0&&&TNV::tnv_fnc(5)){ # has_focus
	my ($k1,$k2,$len)=&TNV::tnv_fnc(2); # get_selected
	if(defined $k2){
	    $k1 =$k2;
	    $k2+=$len;
	    ($k1,$k2)=($k2,$k1) if $k1>$k2;
	}else{
	    $k2=$k1;
	}
	for(my $k=$k2;$k>=$k1;$k--){
	    $del->($k);
	    &do_rm_entry($k);
	}
    }else{
	$del->($kf);
	&do_rm_entry($kf);
    }
}

&show_image($kf,1);
&TNV::set_ctid(undef,1) if $tnvmode>=0;

1;
